package com.hlf.modules.merchant.merchant.controller;

import com.hlf.common.utils.PageUtils;
import com.hlf.common.utils.Query;
import com.hlf.common.utils.ReturnResult;
import com.hlf.modules.merchant.merchant.entity.Merchant;
import com.hlf.modules.merchant.merchant.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/11/13.
 * 商家列表
 */
@RestController
@RequestMapping("sys/merchant")
public class MerchantController {

    @Autowired
    private MerchantService merchantService;

    /**
     * 商户列表
     * @param params
     * @return
     */
    @RequestMapping("/list")
    public ReturnResult list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        Query query = new Query(params);
        List<Merchant> merchantList = merchantService.queryList(query);
        int total = merchantService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(merchantList, total, query.getLimit(), query.getPage());

        return ReturnResult.ok().put("page", pageUtil);
    }


}
